﻿<UserControl x:Class="SystemModule.Views.AddNewUserView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="720" d:DesignWidth="900">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Infrastructure;component/Themes/CommonTemplates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel>
            <TextBlock Margin="40,10,0,0" Text="Thêm mới người dùng" 
                       FontWeight="Bold" Foreground="#FF7A7A7A" HorizontalAlignment="Left"  FontFamily="Segoe UI" FontSize="16" />
            <Rectangle Fill="#FFD6D6D6" Height="1" Margin="0,10 0,15" />
        </StackPanel>
        <Grid  Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="135" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Text="Tên tài khoản:" Grid.Row="0"  Style="{StaticResource TextBlockStyle}"/>
            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding TenTaiKhoan,Mode=TwoWay}" />

            <TextBlock Text="Đơn vị:" Grid.Row="1"  Style="{StaticResource TextBlockStyle}"/>
            <telerik:RadComboBox Grid.Column="1" Grid.Row="1" Name="radComboBox1" Margin="0,0,0,15"
                                     SelectedItem="{Binding CurrentDonVi, Mode=TwoWay}" ItemsSource="{Binding DonViList}"
                                     DisplayMemberPath="TenGoi" />

            <TextBlock Text="Quyền:" Grid.Row="2"  Style="{StaticResource TextBlockStyle}"/>
            <ListBox x:Name="Quyen" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch"
                     SelectionMode="Multiple"
                     SelectionChanged="Quyen_SelectionChanged"
                     ItemsSource="{Binding QuyenList}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="IsSelected" 
                Value="{Binding IsSelected}"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Border Background="Transparent" Margin="{TemplateBinding Padding}">
                                        <CheckBox Content="{Binding TenGoi}" VerticalContentAlignment="Center"
                                    IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>

            </ListBox>
            <!--SelectionChanged="Courses_SelectionChanged"/>-->

            <StackPanel Grid.Column="1" Grid.Row="8" Orientation="Horizontal" HorizontalAlignment="Right">
                <telerik:RadButton Content="Lưu lại" HorizontalAlignment="Right" Name="radButton1" Width="75" Command="{Binding AddNewCommand}" />
                <telerik:RadButton Content="Hủy bỏ" HorizontalAlignment="Right" Name="radButton2" Width="75" Command="{Binding CancelCommand}"/>
            </StackPanel>
            <DataGrid x:Name="gvSelectedCourses" ItemsSource="{Binding SelectedQuyenList}" Grid.Row="3" Grid.ColumnSpan="2"  AutoGenerateColumns="False" Width="300">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="ID" Binding="{Binding ID}" Width="100"/>
                    <DataGridTextColumn Header="Ten" Binding="{Binding TenGoi}"  Width="100"/>
                    <DataGridTextColumn Header="Constraint" Binding="{Binding QuyenConstraint}"  Width="100"/>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </Grid>
</UserControl>
